<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head th:replace="layout :: common_header(~{::title})">
    <title>商品优化管理- 淘宝店铺</title>
</head>

<body th:replace="layout :: common_body(~{::div.layui-body})">

    <div class="layui-body" style="padding:15px;">
        <style type="text/css">
            .update {
                display: inline-block;
                margin-left: 15px;
                padding: 0 20px;
                height: 40px;
                line-height: 40px;
                font-size: 14px;
                background: #009789;
                color: #fff;
                text-align: center;
                border-radius: 3px;
                cursor: pointer;
            }

            .update i {
                display: inline-block;
                margin-right: 10px;
                vertical-align: middle;
                width: 30px;
                height: 30px;
                background: url();
            }

            .T-box {
                width: 400px;
                padding: 0 20px;
                text-align: left;
            }

            .T-box p {
                position: relative;
                height: 36px;
                line-height: 36px;
                font-size: 14px;
                margin-bottom: 15px;
            }

            .T-box p span {
                display: inline-block;
                padding-right: 15px;
                text-align: right;
                width: 110px;
                line-height: 36px;
                font-size: 14px;
            }

            .T-box p input,
            .T-box p select {
                width: 250px;
                padding: 0 5px;
                height: 34px;
                line-height: 34px;
                font-size: 14px;
                border: 1px solid #d3d3d3;
                outline: none;
            }

            .T-box p i {
                padding: 0 10px;
                line-height: 36px;
                font-style: normal;
            }

            .T-box p b {
                display: inline-block;
                margin-left: 10px;
                cursor: pointer;
                width: 60px;
                height: 36px;
                line-height: 36px;
                background: #c33;
                color: #fff;
                text-align: center;
                font-size: 13px;
                font-weight: normal;
            }

            .yinc {
                display: none;
            }
        </style>
        <div class="layui-tab layui-tab-brief" lay-filter="demo">
            <ul class="layui-tab-title">
           
                <li ><a th:href="@{/tao/dashboard(shopId=${shopId})}">首页</a></li>
                <li><a th:href="@{/tao/order_list(shopId=${shopId})}">订单管理</a></li>
                <!-- <li><a th:href="@{/tao/order_create(shopId=${shopId})}">手动创建订单</a></li> -->
                <li><a th:href="@{/tao/refund_list(shopId=${shopId})}">退货管理</a></li>
                <li ><a th:href="@{/tao/goods_list(shopId=${shopId})}">商品管理</a></li>
                <li ><a th:href="@{/tao/goods_traffic_list(shopId=${shopId})}">商品流量管理</a></li>
                <li class="layui-this"><a th:href="@{/tao/goods_optimization_record(shopId=${shopId})}">商品优化记录</a></li>
          
            </ul>
        </div>

        <!-- content starts -->
        <!--    <blockquote class="layui-elem-quote">订单总览</blockquote>-->

        <fieldset class="layui-elem-field">
            <legend>按条件搜索</legend>
            <div class="layui-field-box">
                <form class="layui-form layui-form-pane1" method="get" action="/tao/goods_optimization_record">

                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <input type="text" name="goodsId" th:value="${goodsId}" placeholder="商品ID"
                                style="width: 200px;" class="layui-input">
                        </div>
                        <div class="layui-inline">
                            <div class="layui-input-inline">
                                <select name="shopId" id="shopId">
                                    <option value="0" selected>请选择店铺</option>
                                    <option th:each="item: ${shops}" th:text="${item.name}" th:value="${item.id}">等待发货
                                    </option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button type="submit" class="layui-btn layui-btn-normal">搜索</button>
                            <i>总共：<span style="color: red" th:text="${totalSize}"></span>条记录</i>
                        </div>

                        <div class="layui-inline">
                            <span id="add_goods" class="layui-btn layui-btn-normal">添加记录</span>
                        </div>
                    </div>


                </form>
            </div>
        </fieldset>

        <!-- start dd-wrapper -->
        <link rel="stylesheet" href="/goods/order.css" />
        <div class="dd-wrapper">
            <table class="dd-table">
                <tr>
                    <th>序号</th>
                    <th>GoodsId</th>
                    <th>原标题</th>
                    <th>销量</th>
                    <th>新标题</th>
                    <th>优化内容</th>
                    <th>优化时间</th>
                    <th>备注</th>

                </tr>
                <tr th:each="item:${lists}">
                    <td th:text="${itemStat.index+1}"></td>

                    <td>
                        <a th:href="@{https://item.taobao.com/item.htm(id=${item.getGoodsId()})}"
                            th:text="${item.getGoodsId()}" target="_blank"></a>
                    </td>
                    <td>
                        <span th:text="${item.oldTitle}"></span>
                    </td>
                    <td>
                        <span th:text="${item.oldSales}"></span>
                    </td>


                    <td><span th:text="${item.newTitle}"></span></td>
                    <td><span th:text="${item.remark}"></span></td>
                    <td><span th:text="${item.date}"></span></td>
                    <td>
                        <b th:text="${item.result}"></b>
                        <span th:attr="data-id=${item.id},result=${item.result}" class="sellerRemark" title="输入处理结果">
                            <i class="layui-icon layui-icon-note"></i>
                        </span>
                    </td>
                </tr>
            </table>
        </div>
        <!-- end dd-wrapper -->
        <div class="layui-box layui-laypage layui-laypage-default pageBox">
            <paging:pager th:value="${pageIndex}" th:rows="${totalSize}" th:size="${pageSize}" />
        </div>
        <script type="text/template" id="send-goods">
        <div class="T-box">
            <p><span>sku编码</span><input type="text" name="express_code"/></p>
            <p class="T-result"><span>&nbsp;</span><em id="erro"></em></p>
        </div>
    </script>
        <script type="text/javascript" src="/goods/Tips/Tips.min.js"></script>
        <script type="text/javascript">
            var layer;
            var $;
            var windowOpen;
            layui.use(['laydate', 'jquery', 'form', 'layer'], function () {
                var laydate = layui.laydate;
                $ = layui.jquery;
                var form = layui.form;
                layer = layui.layer;
                laydate.render({
                    elem: '#startTime'
                    , type: 'datetime'
                });
                laydate.render({
                    elem: '#endTime'
                    , type: 'datetime'
                });

                $(function () {
                    var status = '[[${status}]]';
                    $("#status").val(status);
                    $("#shopId").val('[[${shopId}]]');
                    //form.render(); //更新全部
                    form.render('select'); //刷新select选择框渲染

                    $(".sellerRemark").click(function () {
                        var id = $(this).attr('data-id');
                        var remarkT = $(this).attr('result');
                        var obj = $(this).siblings('b').eq(0);

                        layer.prompt({
                            formType: 2,
                            value: remarkT,
                            title: '请处理结果'
                        }, function (value, index, elem) {
                            var data = { id: id, result: value };
                            $.ajax({
                                url: "/ajax_todo/todo_handle",
                                type: "POST",
                                dataType: "JSON",
                                contentType: 'application/json',
                                data: JSON.stringify(data),
                                success: function (res) {

                                    if (res.code == 0) {

                                        $(obj).text(value);
                                        layer.close(index)
                                        layer.msg(res.msg);
                                        $(obj).parent().siblings().eq(7).text("处理中");
                                        $(obj).parent().siblings().eq(8).html('<a class="layui-btn-warm layui-btn-sm todoCompleted" style="color: #fff; " href="javascript:;" data-id="' + id + '">完结</a>')
                                        // location=location;
                                        //<a class="layui-btn-warm layui-btn-sm todoCompleted" style="color: #fff; " href="javascript:;" data-id="90">完结</a>
                                    } else
                                        layer.alert(res.msg);
                                }
                            });


                        });
                    });

                    $("#add_goods").click(function () {
                        layer.open({
                            type: 2,
                            title: '添加商品优化记录',
                            shadeClose: true,
                            shade: 0.8,
                            area: ['600px', '50%'],
                            content: '/tao/goods_optimization_record_add?shopId=[[${shopId}]]'
                        });
                    })

                })



            });

        </script>

    </div>
</body>
<html>